<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改院内超期未录入配置')"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-cqniyjz-edit" th:object="${sysDept}">
        <input name="deptId" type="hidden" th:field="*{deptId}"/>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">暂存点名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" readonly="true" th:field="*{deptName}"/>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">超期未录入预警开关：</label>
            <div class="col-sm-8">
                <label class="toggle-switch switch-solid">
                    <input type="checkbox" id="overdueNotinputSwitch" th:checked="${sysDept.overdueNotinputSwitch == '0' ? true : false}">
                    <span></span>
                </label>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">超期未录入预警值(h)：</label>
            <div class="col-sm-8">
                <input name="overdueNotinputHours"class="form-control" type="number" maxlength="3"
                       oninput="inputHours(this)" th:field="*{overdueNotinputHours}" required>
                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 超期未录入预警值不能小于24小时 </span>
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js" />
<script type="text/javascript">

    $(function () {
    });


    function submitHandler() {
        if ($.validate.form()) {
            var overdueNotinputHours = $("input[name='overdueNotinputHours']").val();
            if( overdueNotinputHours < 24 ){
                $.modal.alertWarning("超期未录入预警值不能小于24小时");
                return;
            }
            var deptId = $("input[name='deptId']").val();
            var overdueNotinputSwitch = $("input[id='overdueNotinputSwitch']").is(':checked') == true ? 0 : 1;
            $.ajax({
                cache : true,
                type : "POST",
                url : ctx + "yf/warning/updateOverdueNotinput",
                data : {
                    "overdueNotinputHours": overdueNotinputHours,
                    "deptId": deptId,
                    "overdueNotinputSwitch": overdueNotinputSwitch
                },
                async : false,
                success : function(data) {
                    $.operate.successCallback(data);
                },
                error : function(request) {
                    $.modal.alertError("系统错误");
                }
            });
        }
    }

    // 修改预警小时,限制大小
    function inputHours(hours){
        if(hours.value < 0){
            hours.value = 0;
        }
        if(hours.value > 999){
            hours.value = 999;
        }
    }


</script>
</body>
</html>
